package relation;

import cn.moukou.dictator.ServerApplication;
import cn.moukou.dictator.dao.node.KVNodeDAO;
import cn.moukou.dictator.dao.relation.KVNODE_RELATION_DAO;
import cn.moukou.dictator.dao.relation.STUDENT_TEACHER_DAO;
import cn.moukou.dictator.pojo.node.KVNode;
import cn.moukou.dictator.pojo.relation.KVNODE_RELATION;
import cn.moukou.dictator.pojo.relation.STUDENT_TEACHER;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

@SpringBootTest(classes = ServerApplication.class)
public class STUDENT_TEACHER_TEST {
    @Autowired
    STUDENT_TEACHER_DAO relationDao;
    @Autowired
    KVNODE_RELATION_DAO kvRelationDao;
    @Autowired
    KVNodeDAO kvDao;

    @Test
    public void addRelation() {
        KVNode start = kvDao.customFindByStudentName("冯璐");
        KVNode end = kvDao.customFindByTeacherName("许梅");
        System.out.println(end);
//        STUDENT_TEACHER r = new STUDENT_TEACHER();
//        r.setStartNode(start);
//        r.setEndNode(end);
//        relationDao.save(r);
    }

    @Test
    public void addKVNODE_RELATION() {
        Iterable<STUDENT_TEACHER> it = relationDao.findAll();
        for (STUDENT_TEACHER st_te : it) {
            System.out.println(st_te);
            KVNODE_RELATION kvRelation = new KVNODE_RELATION();
            kvRelation.setStartNode(st_te.getStartNode());
            kvRelation.setEndNode(st_te.getEndNode());
            kvRelation.setRelationType("student_teacher");
            kvRelation.setRelationLabel("st_te");
            kvRelationDao.save(kvRelation);
        }
    }
}
